package com.funny.stock.trade.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author pengl
 * @date 2020/05/17
 **/
@RestController
@RequestMapping("/compose/assets")
public class ComposeAssetsController {
    public static final Logger logger = LoggerFactory.getLogger(ComposeAssetsController.class);

//    @Autowired
//    ComposeAssetsService composeAssetsService;

//    @Autowired
//    HttpSession httpSession;

//    @PostMapping("/add")
//    public Result<ComposeAssetsVO> add(@RequestBody ComposeAssetsVO dataObj){
//        logger.info("add ComposeAssetsVO");
//        Long userId = UserSecurityUtil.getUserId();
//
//        ComposeAssetsVO assetsVO = composeAssetsService.findByUserIdAndComposeId(userId, dataObj.getComposeId());
//        if(assetsVO == null) return ResultUtil.error("资产模拟组合不存在，请先创建模拟组合");
//
//        assetsVO.setUpdateId(userId);
//        assetsVO.setUpdateTime(new Date());
//        assetsVO.setBalance(dataObj.getBalance());
//        assetsVO.setCapital(dataObj.getCapital());
//
//        ComposeAssetsVO result = composeAssetsService.save(assetsVO);
//        return ResultUtil.success(result);
//    }

//    @GetMapping("/{id}")
//    public Result<ComposeAssetsVO> detail(@PathVariable Long id){
//        Long userId = UserSecurityUtil.getUserId();
//        ComposeAssetsVO detailVO = composeAssetsService.findByCreateIdAndId(userId,id);
//
//        return ResultUtil.success(detailVO);
//    }

//    @GetMapping("/listByPage")
//    public Result<Page<ComposeAssetsVO>> listByPage(@RequestParam(defaultValue = "1") Integer pageNum,
//                                                     @RequestParam(defaultValue = "20") Integer pageSize){
//
//        Page<ComposeAssetsVO> page = composeAssetsService.findAll(PageUtil.buildPageRequest(pageNum, pageSize));
//        return ResultUtil.success(page);
//    }
//
//    @PostMapping("/queryByPage")
//    public Result<Page<ComposeAssetsVO>> myListByPage(@RequestParam(defaultValue = "1") Integer pageNum,
//                                                       @RequestParam(defaultValue = "20") Integer pageSize,
//                                                       @RequestBody ComposeAssetsVO queryVO){
//
//        Long userId = UserSecurityUtil.getUserId();
//        queryVO.setUserId(userId);
//
//        Page<ComposeAssetsVO> page = composeAssetsService.queryByCondition(queryVO,pageNum, pageSize);
//        return ResultUtil.success(page);
//    }

//    @PostMapping("/delete/{id}")
//    public Result<String> delete(@PathVariable long id){
//        Long userId = UserSecurityUtil.getUserId(httpSession);
//        ComposeAssetsVO queryVO = composeAssetsService.findByCreateIdAndId(userId, id);
//        if(queryVO != null) {
//            composeAssetsService.delete(queryVO);
//            return ResultUtil.success(null);
//        }
//        return ResultUtil.error("delete error with id:"+id);
//    }
//
}
